from chardet.universaldetector import UniversalDetector


class CheckDetectEncode:

    def detector_file_encoding(self, file_name) -> str:
        detector = UniversalDetector()
        with open(file_name, 'rb') as fh:
            for line in fh:
                detector.feed(line)
                if detector.done:
                    break
            detector.close()
        return detector.result['encoding']
